#ifndef ADMIN_DB_MANAGER
#define ADMIN_DB_MANAGER

#include "datatablemanagerbase.h"

class TopicTableManager : public DataTableManagerBase
{
public:
    TopicTableManager( QObject * parent );
    ~TopicTableManager();
    void updateModel( int row, const Topic & topic );

protected:
    virtual bool selectToTableModel( const QString & filterStr ); 
};

class QuestionTableManager : public DataTableManagerBase
{
public:
    QuestionTableManager( QObject * parent, QVector<Question> & questionVector );
    ~QuestionTableManager();
    void updateModel( int row, const Question & question );

protected:
    virtual bool selectToTableModel( const QString & filterStr );

private:
    QVector<Question> & m_questionVector;
};

class TopicManager : public ManagerBase
{
public:
    TopicManager( QWidget * parent );
    ~TopicManager();
    virtual DataTableManagerBase & dataTableManager();
    virtual void executeAction( int actionId, int standardModelRow = -1, const QStandardItem * item = NULL );
    virtual void executeDoubleClickAction( int standardModelRow, const QStandardItem * item = NULL ); 

private:
    void add();
    void update( int row, const qint64 & id );
    void remove( int row, const qint64 & id  );

private:
    TopicTableManager m_topicTableManager;
};

class TopicDbManager
{
public:
    static bool insertTopicToDb( SqlCommand & sqlCommand, const Topic & topic, qint64 & newId );
    static bool updateTopicInDb( SqlCommand & sqlCommand, const Topic & topic );
    static bool deleteTopicFromDb( SqlCommand & sqlCommand, const qint64 & id );
    static bool selectTopicDetailsFromDb( const qint64 & id, Topic & topic );
    static bool readTopicsIdVector( int topicCategory, int minimumQuestionCount, QVector<qint64> & topicIdVector );
};

#endif
